using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.Xpo;
namespace TaiLieu
{
    public class MembersDB : Base
    {
        public static Members login(string userName, string pass)
        {
            XPCollection<Members> _xpMember = new XPCollection<Members>(KetNoiCSDL.session);
            string pass1 = maHoa.GetMD5HashData(pass);
            string userName1 = userName;
            string filter = Colum_Members.Username + "='" + userName1 + "' and " + Colum_Members.Pass + "='" + pass1 + "'";
            Members Members = new Members(KetNoiCSDL.session);
            Members = KetNoiCSDL.session.FindObject<Members>(DevExpress.Data.Filtering.CriteriaOperator.Parse(filter));
            if (Members != null)
            {
                return Members;
            }
            return null;
        }
        public static Members GetObjectByid(int id, bool admin)
        {
            return KetNoiCSDL.session.GetObjectByKey<Members>(id);
        }
        public static bool Get_UserName(string mail)
        {
             XPCollection<Members> _xpMember = new XPCollection<Members>(KetNoiCSDL.session);
             string filter = Colum_Members.Username + "='" + mail + "' and Active=true";
            Members mem =  KetNoiCSDL.session.FindObject<Members>(DevExpress.Data.Filtering.CriteriaOperator.Parse(filter));
            if (mem != null)
            { return true; }
            return false;
        }
    }
}
